<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author: LJQ <245369209@qq.com> 
// +----------------------------------------------------------------------

namespace app\inspection\model;
use app\common\model\Base;

/**
 * 巡检任务
 */
class Problem extends Base{

	protected $name = "inspectionproblem";
	protected $createTime = 'createTime';
	protected $updateTime = 'updateTime';

	
	public function getIssueLevelList() {
		$issueLevelList = db('basicinfo')->where('sysCode',26)->column('subsystemName','subsystemNo');
		return $issueLevelList;
	}
	
	public function getIssueLevelAttr($value,$data){
		if($data['issueLevel']){
			$issueLevelList = $this->getIssueLevelList();
			return $issueLevelList[$data['issueLevel']];
		}
		return null;
	}
	
	public function getOperationTimeAttr($value,$data){
		if($data['operationTime']){
			return date('Y-m-d H:i:s',$data['operationTime']);
		}
		return null;
	}
	/**
	 * 巡检人
	 */
	public function checkPerson(){

		return $this->hasOne('app\common\model\User','id','inspectionPerson');
	}
	
	/*
	 * 处理人
	 */
	public function operationPerson(){
		return $this->hasOne('app\common\model\User','id','operationId');
	}
	
	/*
	 * 巡检项
	 */
	public function item(){
		return $this->hasOne('Item','id','inspectionItemId');
	}
	
	/**
	 * 巡检记录
	 */
	public function record(){
		return $this->hasOne('Record','id','inspectionRecordId');
	}
}